package com.hualan.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hualan.sfzy.constant.CommonConstant;
import com.hualan.sfzy.mapper.UerCollectOrderMapper;
import com.hualan.sfzy.model.entity.Course;
import com.hualan.sfzy.model.vo.UerCollectOrder;
import com.hualan.sfzy.service.UerCollectOederService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class UerCollectOrderServiceImpl implements UerCollectOederService {
    @Autowired
    private UerCollectOrderMapper uerCollectOrderMapper;

    @Override
    public Map<String, Object> findByUerId(Integer pageNum, Integer pageSize, int userid) {
        PageHelper.startPage(pageNum, pageSize);
        List<UerCollectOrder> list = uerCollectOrderMapper.selectUerCollectOrder(userid);
        PageInfo<UerCollectOrder> pageInfo = new PageInfo<>(list);
        Map<String, Object> resultMap = new HashMap<>();

        resultMap.put(CommonConstant.PAGE_LIST, list);    // 当前页数据列表
        resultMap.put(CommonConstant.TOTAL, pageInfo.getTotal());      // 总记录数
        resultMap.put(CommonConstant.PAGE_NUM, pageInfo.getPageNum()); // 当前页码
        resultMap.put(CommonConstant.PAGE_SIZE, pageInfo.getPageSize()); // 每页大小
        resultMap.put(CommonConstant.PAGE_TOTAL, pageInfo.getPages());  // 总页数

        return resultMap;
    }
}
